Skip to content

[rv_core_ibex] Add u-mode performance counters and mcounteren#30135

Open
SamuelRiedel wants to merge 4 commits into
lowRISC:masterfrom
SamuelRiedel:mcounteren
Open

[rv_core_ibex] Add u-mode performance counters and mcounteren#30135
SamuelRiedel wants to merge 4 commits into
lowRISC:masterfrom
SamuelRiedel:mcounteren

Conversation

@SamuelRiedel
Copy link
Copy Markdown
Contributor

@SamuelRiedel SamuelRiedel commented May 18, 2026

  • Update Ibex to contain the u-mode performance counter aliases
  • Ibex also implements the mcounteren CSR to control which u-mode counters are accessible
  • The mcounteren CSR can be locked through an input signal to prevent modifying it even in m-mode
  • Add a mcounteren_writable register in rv_core_ibex driving the above signal. This register is lockable with the mcounteren_writable_regwen register.

ToDo:

  • Add sofware test to ensure the newly added registers are writable, lockable, and correctly lock the mcounteren register in Ibex
  • Use consistent MuBi encoding between Ibex and OT.
  • Update Ibex once Add mcounteren register ibex#2403 is merged

@SamuelRiedel SamuelRiedel force-pushed the mcounteren branch 2 times, most recently from 3baeac4 to a204ac4 Compare May 29, 2026 16:22
@SamuelRiedel SamuelRiedel marked this pull request as ready for review May 29, 2026 16:22
@SamuelRiedel SamuelRiedel requested review from a team as code owners May 29, 2026 16:22
@SamuelRiedel SamuelRiedel requested review from gautschimi, rswarbrick and timothytrippel and removed request for a team May 29, 2026 16:22
Copy link
Copy Markdown
Contributor

@gautschimi gautschimi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks all good.

changes in this PR are approved. But the vendor-in commit needs to be updated once the ibex PR has been merged.

edit: commit messages could be a bit longer:)

edit: and the CI jobs need to be fixed

Copy link
Copy Markdown
Contributor

@rswarbrick rswarbrick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the "Add missing rvfi ports" commit be squashed with the vendoring update? Otherwise, I think we have a (slightly) broken intermediate state of the repository?

regwen);

// Since MCOUNTEREN_WRITABLE is True, writes to mcounteren should succeed.
csr_write_mcounteren(0x5);
Copy link
Copy Markdown
Contributor

@rswarbrick rswarbrick Jun 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this using a hex constant instead of a define?

(Maybe the value doesn't really matter? But it still makes sense to stick it in a variable to avoid having to write a magic number in multiple places)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no good reason for this. I added a define now and fixed it.

Signed-off-by: Samuel Riedel <sriedel@lowrisc.org>
Update code from upstream repository
https://github.com/samuelriedel/ibex.git to revision
c799da7a4de7e88e6db9768707541b79b610e3e1

Signed-off-by: Samuel Riedel <sriedel@lowrisc.org>
Signed-off-by: Samuel Riedel <sriedel@lowrisc.org>
Signed-off-by: Samuel Riedel <sriedel@lowrisc.org>
@SamuelRiedel
Copy link
Copy Markdown
Contributor Author

Should the "Add missing rvfi ports" commit be squashed with the vendoring update? Otherwise, I think we have a (slightly) broken intermediate state of the repository?

Yes good point. I will squash the two once we merge the Ibex PR and I vendor in Ibex from the main branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants